package patientAdministration;

import entity.Bill;
import entity.PlanProcedure;
import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

@Stateless
public class BillSessionBean implements BillSessionBeanRemote {

    @PersistenceContext
    private EntityManager entityManager;
    
    @Override
    public Long addBill(List<PlanProcedure> procedureList){
        Bill bill = new Bill();
        bill.setProcedures(procedureList);
        bill.setGenerateDate(new java.sql.Date(0));
        entityManager.persist(bill);
        entityManager.flush();
        return bill.getId();
    }
    
    @Override
    public void deleteBill(Long id){
        Bill b = entityManager.find(Bill.class, id);
        entityManager.remove(b);
        entityManager.flush();
    }
}
